package com.mixsmart.commonweb.dao.impl;

import java.util.HashMap;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.mixsmart.commonweb.bean.entity.TCUser;
import com.mixsmart.commonweb.dao.SortNumDao;
import com.mixsmart.core.IMixSmart;
import com.mixsmart.core.xml.sqlmap.SqlMapUtils;
import com.mixsmart.core.xml.sqlmap.bean.SqlUnit;
import com.mixsmart.utils.StringUtils;

/**
 * 用户DAO
 * @author lmq
 * @version 1.0
 * @since JDK版本大于等于1.6
 * 2016年1月26日
 */
@Repository
public class UserDao extends SortNumDao<TCUser> {

	private static final Logger logger = Logger.getLogger(UserDao.class);
	
	@Override
	public boolean delete(String id) {
		boolean is = false;
		logger.debug("正在用户删除数据.....");
		if(StringUtils.isNotEmpty(id)) {
			String[] ids = id.split(IMixSmart.MULTI_VALUE_SPLIT);
			SqlUnit sqlUtil = SqlMapUtils.getSql("delete_user");
			if(null != sqlUtil) {
				String[] delSqlArray = sqlUtil.getSql().split(IMixSmart.MULTI_STATEMENT_SPLIT);
				HashMap<String, Object> params = new HashMap<String, Object>();
				params.put("ids", ids);
				for (String delSql : delSqlArray) {
					super.deleteSql(delSql, params);
				}
				delSqlArray = null;
			}
			is = true;
			logger.debug("用户数据删除---[成功]---");
		}
		return is;
	}
	
}
